import {AxiosResponse} from "axios";
import api from "./init";
import {Result} from "@/types/api-common";
import {FriendRequest} from "@/types/friend-request";

/**
 * @author FlanChan
 * @description 获取好友申请列表
 */
export const getFriendApplyListApi = (): Promise<
    AxiosResponse<Result<FriendRequest[]>>
> => {
    return api.get("/friend/apply/list");
};
/**
 * @author FlanChan
 * @description 接受好友申请
 */
export const acceptFriendApplyApi = (
    requestId: string
): Promise<AxiosResponse<Result<void>>> => {
    return api.put(`/friend/apply/accept/${requestId}`);
};

/**
 * 获取好友请求总数
 * @author FlanChan
 * @description 统计受到的好友请求总数
 * @returns {Promise<AxiosResponse<Result<number>>>} 受到的好友请求总数
 */
export const countFriendRequestsApi = (): Promise<AxiosResponse<Result<number>>> => {
    return api.get("/friend/apply/unread");
};


/**
 * @author FlanChan
 * @description 拒绝好友申请
 */
export const rejectFriendApplyApi = (
    requestId: string
): Promise<AxiosResponse<Result<void>>> => {
    return api.put(`/friend/apply/reject/${requestId}`);
};